home *** CD-ROM | disk | FTP | other *** search
Wrap
'************************************************************************** '* Professor MULTIMEDIA Setup Script '************************************************************************** '' Define DEBUG for script debugging '$INCLUDE 'setupapi.inc' '$INCLUDE 'msdetect.inc' ''Dialog ID's CONST WELCOME = 100 CONST NODSPACE = 101 CONST ASKQUIT = 200 CONST DESTPATH = 300 CONST EXITFAILURE = 400 CONST EXITQUIT = 600 CONST EXITSUCCESS = 700 CONST WHICHINST = 800 CONST APPHELP = 900 CONST WHICHINSTHLP = 910 CONST TESTSOUND = 1100 CONST INSTALLDRV = 1200 CONST SOUNDPLAYED = 1300 CONST WAITDLG = 1400 CONST EXITREBOOT = 1500 CONST BBD1 = 5000 CONST BBD6 = 5050 CONST SOUNDSDLG = 5200 CONST CUSTINST = 6200 CONST TOOBIG = 6300 CONST BADPATH = 6400 '' For message boxes CONST MB_YESNO=4 CONST IDNO=7 CONST IDYES=6 ''Bitmap ID CONST LOGO = 1 ''File Types CONST BASEFILES = 1 CONST SOUNDFILES = 3 ''Install directories, etc. GLOBAL DEST$ ''Default destination directory. GLOBAL WINDRIVE$ ''Windows drive letter. GLOBAL CUIDLL$ ''CUI DLL GLOBAL WINDIR$ ''Windows directory GLOBAL SYSDIR$ ''System directory GLOBAL WININI$ ''"win.ini" GLOBAL SYSINI$ ''GetWindowsDir() + "system.ini" GLOBAL CDDRV$ ''EUB - CDROM drive root directory ''Install item lists GLOBAL BASE$ ''List of base files GLOBAL SOUNDS$ ''List of all sounds. GLOBAL BASEINST$ ''List of base files to install (subset of BASE$) GLOBAL SOUNDSINST$ ''List of sounds to install (subset of SOUNDS$) ''Custom Install list symbol names GLOBAL BASENEEDS$ ''Option list costs per drive GLOBAL SOUNDNEEDS$ GLOBAL EXTRACOSTS$ ''List of extra costs to add per drive ''Custom Install dialog list symbol names GLOBAL CHECKSTATES$ ''List of check box values GLOBAL STATUSTEXT$ ''List of values to initialize status items GLOBAL DRIVETEXT$ ''Drive space info, etc. '' Install DSOUND GLOBAL INSTDSOUND% '' Customize product GLOBAL CUSTOMIZE% '' Test sound hardware GLOBAL DOTEST% GLOBAL PMMFOUND% GLOBAL CUSTINSTALL% '' Which type of install to perform, by default GLOBAL DEFINSTOPT$ ''Progman titles GLOBAL PMMAPP$ ''Name of PMM app ''Win.ini [ProfMultiMedia] install code GLOBAL INSTDIR$ ''Space requirements GLOBAL FITS% '' > 0 if everything fits DECLARE SUB RecalcOptFiles (ftype%) DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING DECLARE FUNCTION GetWindowsVersionCorrectly& () DECLARE FUNCTION MakeVer& (x as integer, y as integer) DECLARE FUNCTION StringInList (s$, y$) AS INTEGER DECLARE FUNCTION sndPlaySound LIB "MMSYSTEM.DLL" (f$, fl%) AS INTEGER DECLARE SUB RemoveSectionFiles (dest$, sect$) DECLARE SUB RemDirectory (d$) DECLARE FUNCTION HasSoundDriver() AS INTEGER DECLARE SUB SendProgmanCommand LIB "CUI.DLL" (s$) '' These are defined in wsf.inc (product-specific) DECLARE SUB SetProductTitles DECLARE FUNCTION InfFile() AS STRING DECLARE FUNCTION MakeInstDir(D$) AS STRING DECLARE SUB AddInfSectionNames (BASE$, SOUNDS$, BASEINST$, SOUNDSINST$) DECLARE SUB RecalcPath DECLARE SUB AddOptFilesToCopyList (ftype%) DECLARE SUB SetDriveStatus DECLARE SUB AddOptFiles DECLARE SUB ConfigureApps DECLARE SUB AddBillboards DECLARE SUB DoUninstall '' This is where it all begins! INIT: CUIDLL$ = "cui.dll" DEFINSTOPT$ = "2" '' "1" = 1st radiobutton selection, "2"=2nd, "3"=3rd INSTDSOUND% = 0 CUSTOMIZE% = -1 DOTEST% = -1 CDDRV$ = GetSymbolValue("STF_SRCDIR") ''EUB - Intallation drive root directory '-- CDDRV$ = MID$(CDDRV$,1,2) + "\MAINMENU\" ''EUB - get the drive string + set dir SetProductTitles HELPPROC$ = "FHelpDlgProc" ''Help dialog procedure SetBitmap CUIDLL$, LOGO '' We don't do Windows 3.0... If GetWindowsVersionCorrectly() < MakeVer(3, 10) Then i% = DoMsgBox("This product requires Windows version 3.10 or greater", PMMAPP$, MB_OK) GOTO DONEFINIFIN End If ''Find location of INF file and create a default dest. dir szInf$ = GetSymbolValue("STF_SRCINFPATH") IF szInf$ = "" THEN szInf$ = GetSymbolValue("STF_CWDDIR") + InfFile() END IF '' Load the INF file ReadInfFile szInf$ '' Construct default strings WINDIR$ = GetWindowsDir() SYSDIR$ = GetWindowsSysDir() WININI$ = "win.ini" SYSINI$ = MakePath(WINDIR$, "system.ini") '' Construct the default install path WINDRIVE$ = MID$(WINDIR$, 1, 1) DEST$ = MakeInstDir(WINDRIVE$) ''---------------------------------------------------------------------- '' We need to install some drivers on the Windows directory, and the TBK '' files into another drive, if we don't have enough space. So we better '' make sure there's enough (NON-COMPRESSED) diskspace available in the '' Windows directory. We need about 507 K of diskspace for these drivers, '' but, let's double this amount, in case the user has DBLSPACE installed '' in his system. '' CHKDSK: free& = GetFreeSpaceForDrive(WINDRIVE$) / 1024 ''i%=DoMsgBox("drive$=" + WINDRIVE$ +" free="+STR$(free&), "Debugging", MB_OK) IF free& < 1024 THEN ''if free diskspace < 1 megabyte sz$ = UIStartDlg(CUIDLL$, NODSPACE, "FInfoDlgProc", 0, "") UIPop 1 IF sz$ = "EXIT" THEN GOSUB TOOBIG END ELSEIF sz$ = "CONTINUE" THEN GOTO CHKDSK END IF GOTO CHKDSK END IF ''---------------------------------------------------------------------- '' Setup install symbols BASE$ = "Base Files" SOUNDS$ = "Sounds" BASEINST$ = "Base Files Inst" SOUNDSINST$ = "Sounds Inst" SetSymbolValue BASE$, "" SetSymbolValue SOUNDS$, "" ''Set up symbols for the initial install dialog RADIODEFAULT$ = "Radio Default" ''Set up symbols for the custom install dialog CHECKSTATES$ = "CheckItemsState" STATUSTEXT$ = "StatusItemsText" DRIVETEXT$ = "DriveStatusText" FOR i% = 1 TO 4 STEP 1 AddListItem CHECKSTATES$, "ON" NEXT i% FOR i% = 1 TO 4 STEP 1 AddListItem STATUSTEXT$, "" NEXT i% FOR i% = 1 TO 7 STEP 1 AddListItem DRIVETEXT$, "" NEXT i% ReplaceListItem DRIVETEXT$, 7, DEST$ ''Disk cost list symbols BASENEEDS$ = "BaseNeeds" SOUNDNEEDS$ = "SoundNeeds" EXTRACOSTS$ = "ExtraCosts" FOR i% = 1 TO 26 STEP 1 AddListItem EXTRACOSTS$, "0" NEXT i% '' Locate sounds for install INSTSNDDIR$ = MakePath(GetSymbolValue("STF_SRCDIR"), "stup\soundfx") ''Configure lists of installable files AddInfSectionNames BASE$, SOUNDS$, BASEINST$, SOUNDSINST$ '$IFDEF DEBUG i% = SetSizeCheckMode(scmOnIgnore) '' could use scmOff; def = scmOnFatal '$ENDIF ''DEBUG '' Display Welcome dialog WELCOME: '' res% = sndPlaySound(MakePath(INSTSNDDIR$, "v1.wav"), 3) sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$) IF sz$ = "EXIT" THEN GOSUB ASKQUIT GOTO WELCOME ELSEIF sz$ = "CONTINUE" THEN UIPop 1 GOTO CUSTOMIZE END IF GOTO WELCOME '' See which install user wants WHICHINST: '' Customize the copy of the product CUSTOMIZE: IF NOT CUSTOMIZE% THEN GOTO SOUNDTEST END IF '' Test the sound system SOUNDTEST: IF NOT DOTEST% THEN GOTO DOINST END IF sz$ = UIStartDlg(CUIDLL$, TESTSOUND, "FInfoDlgProc", WHICHINSTHLP, HELPPROC$) IF sz$ = "EXIT" THEN GOSUB ASKQUIT GOTO SOUNDTEST ELSEIF sz$ = "CONTINUE" THEN UIPop 1 IF HasSoundDriver() THEN GOTO DOINST ELSE GOTO INSTDSOUND END IF ELSEIF sz$ = "TEST" THEN w$ = MakePath(INSTSNDDIR$, "test123.wav") res% = sndPlaySound(w$, 2) UIPop 1 GOTO DIDPLAY END IF GOTO SOUNDTEST '' Did the sound play? DIDPLAY: sz$ = UIStartDlg(CUIDLL$, SOUNDPLAYED, "FInfoDlgProc", WHICHINSTHLP, HELPPROC$) IF sz$ = "EXIT" THEN GOSUB ASKQUIT GOTO DIDPLAY ELSEIF sz$ = "YES" THEN UIPop 1 GOTO DOINST ELSEIF sz$ = "NO" THEN UIPop 1 GOTO INSTDSOUND ELSEIF sz$ = "BACK" THEN UIPop 1 GOTO SOUNDTEST END IF GOTO DIDPLAY '' Install DSOUND INSTDSOUND: sz$ = UIStartDlg(CUIDLL$, INSTALLDRV, "FInfoDlgProc", WHICHINSTHLP, HELPPROC$) IF sz$ = "EXIT" THEN GOSUB ASKQUIT GOTO INSTDSOUND ''--ELSEIF sz$ = "INSTALL" THEN '' UIPop 1 '' INSTDSOUND% = -1 '' GOTO DOINST '' ELSEIF sz$ = "CONTINUE" THEN '' UIPop 1 ''------GOTO DOINST ELSEIF sz$ = "BACK" THEN UIPop 1 GOTO DIDPLAY END IF GOTO INSTDSOUND '' Do the appropriate type of install DOINST: IF CUSTINSTALL% THEN GOTO CUSTINST END IF '' else fall-thru ''Perform a default installation (of all files and options) DEFINST: RecalcPath SetDriveStatus GETDEFINSTPATH: GOSUB GETPATH IF sz$ = "CONTINUE" THEN ''Install only if it will fit. IF FITS% > 0 THEN GOSUB TOOBIG GOTO GETDEFINSTPATH END IF UIPop 1 GOTO INSTALL ELSEIF sz$ = "BACK" THEN GOTO CUSTOMIZE END IF GOTO GETDEFINSTPATH ''Perform a custom installation (let user choose files, etc) CUSTINST: RecalcPath SetDriveStatus '' res% = sndPlaySound(MakePath(INSTSNDDIR$, "v4.wav"), 3) CUSTINSTDLG: sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$) IF sz$ = "CONTINUE" THEN ''Install only if it will fit. IF FITS% > 0 THEN GOSUB TOOBIG GOTO CUSTINSTDLG END IF UIPop 1 GOTO INSTALL ELSEIF sz$ = "PATH" THEN '' res% = sndPlaySound(MakePath(INSTSNDDIR$, "v5.wav"), 3) GOSUB GETPATH GOTO CUSTINSTDLG ELSEIF sz$ = "CHK1" THEN RecalcOptFiles BASEFILES SetDriveStatus GOTO CUSTINSTDLG ELSEIF sz$ = "CHK3" THEN RecalcOptFiles SOUNDFILES SetDriveStatus GOTO CUSTINSTDLG ELSEIF sz$ = "BTN3" THEN GOTO SOUNDFILES ELSEIF sz$ = "EXIT" THEN GOSUB ASKQUIT GOTO CUSTINST END IF GOTO CUSTINSTDLG INSTALL: SetRestartDir DEST$ ClearCopyList AddOptFiles AddBillboards BACKLASH: IF (MID$(DEST$, (LEN(DEST$)), 1)) = "\" THEN DEST$ = MID$(DEST$, 1, (LEN(DEST$)-1)) GOTO BACKLASH END IF CreateDir DEST$, cmoNone UIPopAll res% = sndPlaySound(MakePath(INSTSNDDIR$, "v6.wav"), 3) ''Do the copyn' SetCopyGaugePosition 10, 135 CopyFilesInCopyList ''Back up SYSTEM.INI and WIN.INI CopyFile MakePath(WINDIR$, WININI$), MakePath(WINDIR$, "WIN.BAK"), cmoOverwrite, 0 CopyFile SYSINI$, MakePath(WINDIR$, "SYSTEM.BAK"), cmoOverwrite, 0 '' Configure the installed applications ConfigureApps ''See if we need to restart Windows to finish installing system files which may be in use IF RestartListEmpty() = 0 THEN i% = DoMsgBox("Certain system files that Setup needs to install are currently in use." + " Please close all other applications and press OK. Setup will exit Windows, install these files, and restart Windows.", PMMAPP$ + " Setup", MB_OK) i% = ExitExecRestart() END IF QUIT: ON ERROR GOTO ERRQUIT IF ERR = 0 THEN res% = sndPlaySound(MakePath(INSTSNDDIR$, "v7.wav"), 3) dlg% = EXITREBOOT ELSEIF ERR = STFQUIT THEN res% = sndPlaySound(MakePath(INSTSNDDIR$, "v8.wav"), 3) dlg% = EXITQUIT ELSE '$IFNDEF DEBUG RESUME NEXT '$ELSE dlg% = EXITFAILURE '$ENDIF END IF QUITL1: sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "") '' res% = sndPlaySound(MakePath(INSTSNDDIR$, "v9.wav"), 2) '' IF sz$ = "REACTIVATE" THEN '' GOTO QUITL1 '' END IF UIPop 1 DONEFINIFIN: END ERRQUIT: res% = sndPlaySound(MakePath(INSTSNDDIR$, "v10.wav"), 3) i% = DoMsgBox("An error has during installation. Please call Individual Software Customer Service at (800) 331-3313!", "Setup Error", MB_OK+MB_TASKMODAL+MB_ICONHAND) END GETPATH: SetSymbolValue "EditTextIn", DEST$ SetSymbolValue "EditFocus", "END" GETPATHL1: sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$) IF sz$ = "CONTINUE" THEN olddest$ = DEST$ DEST$ = GetSymbolValue("EditTextOut") ''Validate new path. VALPATH: IF (MID$(DEST$, (LEN(DEST$)), 1)) = "\" THEN DEST$ = MID$(DEST$, 1, (LEN(DEST$)-1)) GOTO VALPATH END IF IF IsDriveValid(MID$(DEST$, 1, 1)) = 0 THEN i% = DoMsgBox("This is not a valid path. Please enter a different path.", APP$, MB_OK) GOTO GETPATHL1 END IF IF (MID$(DEST$, 2, 1)) <> ":" THEN i% = DoMsgBox("This is not a valid path. Please enter a different path.", APP$, MB_OK) GOTO GETPATHL1 END IF IF NETINSTALL%=0 THEN IF IsDriveNetwork(MID$(DEST$, 1, 1)) > 0 THEN i% = DoMsgBox("This is network drive. Please enter a different path.", APP$, MB_OK) GOTO GETPATHL1 END IF END IF SetDriveStatus IF FITS% > 0 THEN GOSUB TOOBIG GOTO GETPATHL1 END IF IF IsDriveRemovable(DEST$) > 0 THEN i% = DoMsgBox("This program must be installed to a hard drive. Please enter a different drive.", APP$, MB_OK) GOTO GETPATHL1 END IF IF DEST$+"\"=GetWindowsSysDir THEN i% = DoMsgBox("This program can not be installed into the Windows directory. Please enter a different path.", APP$, MB_OK) GOTO GETPATHL1 END IF IF DEST$+"\"=GetWindowsDir THEN i% = DoMsgBox("This program can not be installed into the Windows directory. Please enter a different path.", APP$, MB_OK) GOTO GETPATHL1 END IF UIPop 1 ''Truncate display if too long. IF LEN(DEST$) > 23 THEN ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..." ELSE ReplaceListItem DRIVETEXT$, 7, DEST$ END IF ''Recalc if path changed. IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN RecalcPath SetDriveStatus END IF olddest$ = "" RETURN ELSEIF sz$ = "EXIT" THEN GOSUB ASKQUIT GOTO GETPATHL1 ELSEIF sz$ = "BACK" THEN UIPop 1 RETURN END IF GOTO GETPATHL1 SOUNDFILES: SetSymbolValue "ListItemsIn", GetSymbolValue(SOUNDS$) SetSymbolValue "ListItemsOut", GetSymbolValue(SOUNDSINST$) SOUNDF: sz$ = UIStartDlg(CUIDLL$, SOUNDSDLG, "FMultiDlgProc", APPHELP, HELPPROC$) IF sz$ = "CONTINUE" THEN UIPop 1 SetSymbolValue SOUNDSINST$, GetSymbolValue("ListItemsOut") RecalcOptFiles SOUNDFILES SetDriveStatus GOTO CUSTINSTDLG ELSEIF sz$ = "EXIT" THEN GOSUB ASKQUIT GOTO SOUNDF ELSE '' Back... UIPop 1 GOTO CUSTINSTDLG END IF GOTO SOUNDF TOOBIG: sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "") UIPop 1 RETURN BADPATH: sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "") UIPop 1 RETURN ASKQUIT: res% = sndPlaySound(MakePath(INSTSNDDIR$, "v12.wav"), 3) sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "") IF sz$ = "EXIT" THEN UIPopAll ERROR STFQUIT ''- ELSEIF sz$ = "REACTIVATE" THEN ''----- GOTO ASKQUIT ELSE UIPop 1 END IF RETURN ''Recalculate space based on install options... SUB RecalcOptFiles (ftype%) STATIC CursorSave% = ShowWaitCursor() sz$ = UIStartDlg(CUIDLL$, WAITDLG, "FModelessDlgProc", APPHELP, HELPPROC$) ClearCopyList AddOptFilesToCopyList ftype% fExtra% = 0 IF ftype% = BASEFILES THEN ListSym$ = BASENEEDS$ IF GetListItem(CHECKSTATES$, BASEFILES) = "ON" THEN ''Add extra cost to Windows drive for ini/progman/pointers ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1 ReplaceListItem EXTRACOSTS$, ndrive%, "2097152" fExtra% = 1 END IF ELSEIF ftype% = SOUNDFILES THEN ListSym$ = SOUNDNEEDS$ END IF StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "") cost& = 0 FOR i% = 1 TO 26 STEP 1 cost& = cost& + VAL(GetListItem(ListSym$, i%)) NEXT i% ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K" IF fExtra% THEN ReplaceListItem EXTRACOSTS$, ndrive%, "0" END IF UIPop 1 RestoreCursor CursorSave% ListSym$ = "" END SUB ''Make path from dir and szFile; add \ as needed FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING IF szDir$ = "" THEN MakePath = szFile$ ELSEIF szFile$ = "" THEN MakePath = szDir$ ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN MakePath = szDir$ + szFile$ ELSE MakePath = szDir$ + "\" + szFile$ END IF END FUNCTION '' Return true if the given string is in the symbol's list FUNCTION StringInList (s$, y$) STATIC AS INTEGER l% = GetListLength(y$) FOR i% = 1 TO l IF s$ = GetListItem(y$, i%) THEN StringInList = -1 GOTO DONE END IF NEXT i% StringInList = 0 DONE: END FUNCTION ''Get Windows version FUNCTION GetWindowsVersionCorrectly& () STATIC GetWindowsVersionCorrectly = GetWindowsMajorVersion() * 256 + GetWindowsMinorVersion() END FUNCTION '' Turn x, y into a major.minor version long FUNCTION MakeVer& (x as integer, y as integer) STATIC MakeVer = x * 256 + y END FUNCTION '' Remove all files in the given .INF section SUB RemoveSectionFiles (dest$, sect$) STATIC foo$ = "foo" MakeListFromSectionFilename foo$, sect$ l% = GetListLength(foo$) FOR i% = 1 TO l% STEP 1 RemoveFile MakePath(dest$, GetListItem(foo$, i%)), cmoForce NEXT i% foo$ = "" END SUB '' Remove directory and all files in it, if it exists SUB RemDirectory(d$) STATIC IF Exists(MakePath(d$, "NUL")) THEN Kill MakePath(d$, "*.*") RmDir d$ END IF END SUB '' Return True (-1) if the user has a sound driver in the [drivers] '' section of win.ini. FUNCTION HasSoundDriver() STATIC AS INTEGER r% = 0 IF GetIniKeyString(SYSINI$, "drivers", "wave") <> "" THEN r% = -1 ELSEIF GetIniKeyString(SYSINI$, "drivers", "wave1") <> "" THEN r% = -1 ELSEIF GetIniKeyString(SYSINI$, "drivers", "wave2") <> "" THEN r% = -1 ELSEIF GetIniKeyString(SYSINI$, "drivers", "wave3") <> "" THEN r% = -1 ELSEIF GetIniKeyString(SYSINI$, "drivers", "wave4") <> "" THEN r% = -1 ELSEIF GetIniKeyString(SYSINI$, "drivers", "wave5") <> "" THEN r% = -1 END IF HasSoundDriver = r% END FUNCTION '' Include product-specific function definitions '$INCLUDE 'specific.inc'